﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows.Controls;
using System.Windows;
using ResourceViewerExtension.Model;
using System.Windows.Media;
using System.Windows.Media.Imaging;

namespace ResourceViewerExtension.Common
{
    public class DetailsItemTemplateSelector : DataTemplateSelector
    {
        public DataTemplate BrushTemplate { get; set; }
        public DataTemplate ImageTemplate { get; set; }

        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {
            if (item == null)
                return null;

            var entry = (EntryModel)item;

            if (entry.Value is DrawingBrush || entry.Value is Brush)
            {
                return BrushTemplate;
            }
            else if (entry.Value is DrawingImage || entry.Value is BitmapImage)
            {
                return ImageTemplate;
            }
            return null;
        }
    }
}
